package com.itheima.bos.web.action;

import com.itheima.bos.domain.Workbill;
import com.itheima.bos.domain.Workordermanage;
import com.itheima.bos.service.IWorkordermanageService;
import com.itheima.bos.web.action.base.BaseAction;
import com.opensymphony.xwork2.ActionContext;
import org.activiti.engine.ProcessEngine;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import java.io.IOException;
import java.util.List;

/**
 * Created by Mr.King on 2017/3/15.
 */
@Controller
@Scope(value = "prototype")
public class WorkordermanageAction extends BaseAction<Workordermanage> {

    @Autowired
    private IWorkordermanageService workordermanageService;


    /**
     *
     *快速录入
    */
    public String save() throws IOException {
        String flag = "1";
        try {
            workordermanageService.save(model);
        }catch (Exception e){
            flag = "0";
        }
        ServletActionContext.getResponse().getWriter().print(flag);
        return NONE;
    }
    /**
     * 分页查询所有
     *
     */
    public String pageQuery() throws IOException {
        setPage();

        workordermanageService.pageQuery(pageBean);

        String[] arr = new String[]{"detachedCriteria", "currentPage", "pageSize","actlweit","feeitemnum","managerCheck",
        "prodtimelimit","prodtype","receivername","receiverphone","receiveraddr","sendername","senderphone","senderaddr",
                "updatetime","vol"};
        toJSON(pageBean,arr);
        return NONE;
    }

    /**
     * 查询状态为未启动的工作单
     */
    public String list(){
        List<Workordermanage> list = workordermanageService.findListNotStart();
        ActionContext.getContext().getValueStack().set("list",list);
        return "list";
    }


    /**
     * 启动工作单
     */
    public String start(){
        workordermanageService.findById(model.getId());
        return "toList";
    }

}
